Skip to content

spotrem: add volume knob gesture #3847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open

Conversation

thyttan
Copy link
Collaborator

@thyttan thyttan commented May 9, 2025

Can be tried at: https://thyttan.github.io/BangleApps/?id=spotrem

Edit:
Adds two new modules for dial functionality, one for touch interaction and one for graphics. This is used in spotrem to provide the volume knob.

@bobrippling
Copy link
Collaborator

Very cool! Works well when I tested it. Do you think it's worth mentioning that the clockwise/anticlockwise gesture detection is stopped after a brief period of no-interaction?

Not for this PR, but if you wanted ideas on going further with this feature, it'd be cool to pull it out to a library and let other apps opt into the clockwise gesture, and during the clockwise gesture, display a circle on screen that follows the user's gesture. But obviously those are much bigger changes!

@thyttan
Copy link
Collaborator Author

thyttan commented May 15, 2025

Thanks :)

Do you think it's worth mentioning that the clockwise/anticlockwise gesture detection is stopped after a brief period of no-interaction?

Yes! Will add that.

[...] it'd be cool to pull it out to a library and let other apps opt into the clockwise gesture, and during the clockwise gesture, display a circle on screen that follows the user's gesture. But obviously those are much bigger changes!

Yes - that's where I started with this. But I switched to this focused implementation first to dial in the UX (pun intended).

@thyttan thyttan marked this pull request as draft May 26, 2025 23:13
@thyttan thyttan requested a review from bobrippling August 12, 2025 21:19
@thyttan
Copy link
Collaborator Author

thyttan commented Aug 12, 2025

@bobrippling this is maybe done now! Please comment any feedback you may have :)

It now adds two new modules for dial functionality, one for touch interaction and one for graphics. This is used in spotrem to provide the volume knob.

@thyttan thyttan marked this pull request as ready for review August 13, 2025 11:13
if (isFill) g.fillCircle(x, y, rad);
}
if (this.isFirstDraw) {
g.setColor(0,0,0).fillCircle(CENTER.x, CENTER.y, 25);
Copy link
Collaborator Author

@thyttan thyttan Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the radii for the drawing operations should not be hardcoded to 25, 23, 9 etc but depend on the DIAL_RECT...

Copy link
Collaborator Author

@thyttan thyttan Aug 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe adding a additional displayRect setting to the options object that if is not set defaults to what the dialRect option is.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think this is ok for now but we could have a follow-up PR which infers a radius from the rect? Or like you say, adds a setting

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, lets leave it as is for now :)

Copy link
Collaborator

@bobrippling bobrippling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bobrippling this is maybe done now! Please comment any feedback you may have :)

It now adds two new modules for dial functionality, one for touch interaction and one for graphics. This is used in spotrem to provide the volume knob.

Great, nice separation of functionality! I spotted a few things, let me know if I've been unclear or if you've any questions :)


```JS
var Dial = require("Dial");
var dial = new Dial(cb, options)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use Dial here as a constructor (no this and it returns an object explicitly) so the new (while it works) might confuse users. What about:

Suggested change
var dial = new Dial(cb, options)
var dial = dial(cb, options)

(suggested lowercase dial as it's no longer a class too, don't mind if you prefer it Titlecase though)

Copy link
Collaborator Author

@thyttan thyttan Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK - if that makes more sense I'm all for it.

I looked at the Layout module for inspiration when developing and taking a quick look now I fail to see how they differ in this regard. Out of interest, do they?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I think I get what you mean now!

Comment on lines +36 to +37
if (!isFill) g.drawCircle(x, y, rad);
if (isFill) g.fillCircle(x, y, rad);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps:

Suggested change
if (!isFill) g.drawCircle(x, y, rad);
if (isFill) g.fillCircle(x, y, rad);
if (!isFill) g.drawCircle(x, y, rad);
else g.fillCircle(x, y, rad);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole drawCircle should be removed I guess, when I think about it. I intended to use it more but now it's only used to make the small marks around the dial. (I had another design in mind at first where there would be small hollow circles around the dial, except for the one the indicator pointed to which would be filled.)

if (isFill) g.fillCircle(x, y, rad);
}
if (this.isFirstDraw) {
g.setColor(0,0,0).fillCircle(CENTER.x, CENTER.y, 25);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think this is ok for now but we could have a follow-up PR which infers a radius from the rect? Or like you say, adds a setting


```JS
var DialDisplay = require("Dial_Display");
var dialDisplay = new DialDisplay(options);
Copy link
Collaborator

@bobrippling bobrippling Aug 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same again (as the other comment), but here I think we'll want to change to make it more class-like, or alter how this is used within the dialDisplay function. At the moment it'll be writing to the global object.

For example, in the IDE:

> cb
=function (step) { ... }
>cb(1)
=undefined
>cb(1)
=undefined

// the dial renders successfully
// `this` variables are written to the global:

>isFirstDraw
=false
>value
=14

Happy to go through a few suggestions for it, if you like

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to go through a few suggestions for it, if you like

Please do! Fun with a learning opportunity :) Feel free to commit to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants